<!--
  -- 描述：根据条件查询组织机构菜单
  --
  -- 作者：cyq
  -- 时间：2018/9/8 9:31
-->
<template>
  <el-select placeholder="请选择机构" :value="mval" @change="selectHandler">
    <el-option v-for="item in list" :key="item.orgcode" :label="item.shortname" :value="item.orgcode"></el-option>
  </el-select>
</template>

<script>
  export default {
    name: "OrgMenu",
    model: {
      prop: 'mval',
      event: 'modelValue'
    },
    props: ['mval', 'orgType', 'parentCode', 'defSelect'],
    mounted: function() {
      this.api.post('/org/queryList', this.params)
        .then((data) => {
          this.list = data.data.records;
          if(this.defSelect && this.list.length>0)
            this.selectHandler(this.list[0].orgcode)
        });
    },
    data() {
      return {
        list: [],
        params: {
          parantcode: this.parentCode,
          orgtype: this.orgType,
          pageNumber: 1,
          pageSize: 100
        }
      }
    },
    methods: {
      selectHandler: function(val){
        this.$emit('modelValue', val);
      }
    }
  }
</script>

